package com.wwk.netty;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @Author wwk
 * @DATE 2022/5/24 13:48
 */
public class WriteServer {
    public static void main(String[] args) {
        //获取客户端channel
        try(SocketChannel sc = SocketChannel.open()) {
            //连接服务端
            sc.connect(new InetSocketAddress("localhost",8080));
            int count = 0;
            //接收数据
            while(true){
                ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024);
                count  += sc.read(buffer);
                System.out.println(count);
                buffer.clear();
            }

        }catch (IOException e) {

        }
    }
}
